<?php

namespace mpend\modules\assist\models;

use Yii;
use common\helpers\Url;

/**
 * 反馈场景模型
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 * @property mixed $link
 */
class FeedbackSceneSearch extends \common\models\feedback\FeedbackScene implements \common\db\SearchModelInterface {

    public $parent_id = 0;

    public $pagesize = false;

    /**
     * @inheritdoc
     */
    public function buildQuery() {
        $query = static::find()
            ->active(static::STATUS_ACTIVE)
            ->andWhere(['parent_id' => $this->parent_id])
            ->orderBy([
                'listorder' => SORT_ASC,
            ]);
        return $query;
    }

    public function getLink() {
        return Url::to(['/feedback/view', 'id' => $this->id]);
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'name',
            'description',
            'link',
            'created_at' => function () {
                return date('Y-m-d', $this->created_at);
            }
        ];
    }

}
